]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Extend ShellGlobal object with more properties
authorOwen Taylor <otaylor@src.gnome.org>
Fri, 31 Oct 2008 15:20:54 +0000 (15:20 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Fri, 31 Oct 2008 15:20:54 +0000 (15:20 +0000)
* Add screen-width, screen-height, overlay-group properties
* Add set_stage_input_area() function
* Fix main.js to rotate DRAFT properly

svn path=/trunk/; revision=6

js/ui/main.js
src/gnome-shell-plugin.c
src/metacity-symbols.c
src/shell-global.c
src/shell-global.h

index 4e68a371c06e35ae23cd24ee260f880470dd4e02..dfc9f9d384419826f287292ce402104ced3e8421 100644 (file)
@@ -6,8 +6,8 @@ function start() {
 
     let message = new Clutter.Label({font_name: "Sans Bold 64px", text: "DRAFT"});
     message.set_opacity(75);
-    // Not working for unclear reasons
-    // message.set_rotation(Clutter.RotateAxis.Z_AXIS, - 45, 0, 0, 0);
-    message.set_position(100, 100);
-    global.get_overlay_group().add_actor(message);
+    message.set_anchor_point_from_gravity (Clutter.Gravity.CENTER);
+    message.set_rotation(Clutter.RotateAxis.Z_AXIS, - 45, 0, 0, 0);
+    message.set_position(global.screen_width / 2, global.screen_height / 2);
+    global.overlay_group.add_actor(message);
 }
index 154b44d4086f1f11b173909e6582542f859c6ecf..5ff0a5a924383bb69ebd09f9217d3e964fe4e128 100644 (file)
@@ -83,7 +83,6 @@ static gboolean
 do_init (const char *params)
 {
   MutterPlugin *plugin = mutter_get_plugin();
-  ClutterActor *overlay_group;
   GError *error = NULL;
   int status;
   const char *shell_js;
@@ -101,9 +100,6 @@ do_init (const char *params)
         }
     }
 
-  overlay_group = mutter_plugin_get_overlay_group (plugin);
-  shell_global_set_overlay_group (shell_global_get(), overlay_group);
-
   shell_js = g_getenv("GNOME_SHELL_JS");
   if (!shell_js)
     shell_js = JSDIR;
@@ -112,6 +108,8 @@ do_init (const char *params)
   plugin_state->gjs_context = gjs_context_new_with_search_path(search_path);
   g_strfreev(search_path);
 
+  _shell_global_set_plugin (shell_global_get(), plugin);
+
   if (!gjs_context_eval (plugin_state->gjs_context,
                          "const Main = imports.ui.main; Main.start();",
                          -1,
index 84e42da8997ca5e6f6f6b927974c11d7942dee84..b542075332c9a5bff0067bb05d533997d9e77178 100644 (file)
@@ -2,13 +2,6 @@
 
 #include <mutter-plugin.h>
 
-void
-mutter_plugin_query_screen_size (MutterPlugin *plugin,
-                                 int          *width,
-                                 int          *height)
-{
-}
-
 ClutterActor *
 mutter_plugin_get_overlay_group (MutterPlugin *plugin)
 {
@@ -20,3 +13,16 @@ mutter_plugin_get_stage (MutterPlugin *plugin)
 {
   return NULL;
 }
+
+void
+mutter_plugin_query_screen_size (MutterPlugin *plugin,
+                                 int          *width,
+                                 int          *height)
+{
+}
+
+void
+mutter_plugin_set_stage_input_area (MutterPlugin *plugin,
+                                    gint x, gint y, gint width, gint height)
+{
+}
index 4fbecd6a214d0a5cf89a6e808e593b10f27fa557..fac6b115c54307daed98c4b1e431c22e69403456 100644 (file)
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
 #include "shell-global.h"
 
 struct _ShellGlobal {
   GObject parent;
 
-  ClutterActor *overlay_group;
+  MutterPlugin *plugin;
 };
 
 struct _ShellGlobalClass {
   GObjectClass parent_class;
 };
 
+enum {
+  PROP_0,
+
+  PROP_OVERLAY_GROUP,
+  PROP_SCREEN_WIDTH,
+  PROP_SCREEN_HEIGHT
+};
+
 G_DEFINE_TYPE(ShellGlobal, shell_global, G_TYPE_OBJECT);
 
+static void
+shell_global_set_property(GObject         *object,
+                          guint            prop_id,
+                          const GValue    *value,
+                          GParamSpec      *pspec)
+{
+  switch (prop_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+shell_global_get_property(GObject         *object,
+                          guint            prop_id,
+                          GValue          *value,
+                          GParamSpec      *pspec)
+{
+  ShellGlobal *global = SHELL_GLOBAL (object);
+
+  switch (prop_id)
+    {
+    case PROP_OVERLAY_GROUP:
+      g_value_set_object (value, mutter_plugin_get_overlay_group (global->plugin));
+      break;
+    case PROP_SCREEN_WIDTH:
+      {
+        int width, height;
+
+        mutter_plugin_query_screen_size (global->plugin, &width, &height);
+        g_value_set_int (value, width);
+      }
+      break;
+    case PROP_SCREEN_HEIGHT:
+      {
+        int width, height;
+
+        mutter_plugin_query_screen_size (global->plugin, &width, &height);
+        g_value_set_int (value, height);
+      }
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
 static void
 shell_global_init(ShellGlobal *global)
 {
 }
 
 static void
-shell_global_class_init(ShellGlobalClass *klass)
+shell_global_class_init (ShellGlobalClass *klass)
 {
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->get_property = shell_global_get_property;
+  gobject_class->set_property = shell_global_set_property;
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_OVERLAY_GROUP,
+                                   g_param_spec_object ("overlay-group",
+                                                        "Overlay Group",
+                                                        "Actor holding objects that appear above the desktop contents",
+                                                        CLUTTER_TYPE_ACTOR,
+                                                        G_PARAM_READABLE));
+  g_object_class_install_property (gobject_class,
+                                   PROP_SCREEN_WIDTH,
+                                   g_param_spec_int ("screen-width",
+                                                     "Screen Width",
+                                                     "Screen width, in pixels",
+                                                     0, G_MAXINT, 1,
+                                                     G_PARAM_READABLE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_SCREEN_HEIGHT,
+                                   g_param_spec_int ("screen-height",
+                                                     "Screen Height",
+                                                     "Screen height, in pixels",
+                                                     0, G_MAXINT, 1,
+                                                     G_PARAM_READABLE));
 }
 
 ShellGlobal *
@@ -34,25 +120,22 @@ shell_global_get (void)
 }
 
 void
-shell_global_set_overlay_group (ShellGlobal  *global,
-                               ClutterActor *overlay_group)
+shell_global_set_stage_input_area (ShellGlobal *global,
+                                   int          x,
+                                   int          y,
+                                   int          width,
+                                   int          height)
 {
-  g_object_ref (overlay_group);
+  g_return_if_fail (SHELL_IS_GLOBAL (global));
 
-  if (global->overlay_group)
-    g_object_unref(global->overlay_group);
-
-  global->overlay_group = overlay_group;
-}
-
-ClutterActor *
-shell_global_get_overlay_group (ShellGlobal  *global)
-{
-  return global->overlay_group;
+  mutter_plugin_set_stage_input_area (global->plugin, x, y, width, height);
 }
 
 void
-shell_global_print_hello (ShellGlobal *global)
+_shell_global_set_plugin (ShellGlobal  *global,
+                          MutterPlugin *plugin)
 {
-  g_print("Hello World!\n");
+  g_return_if_fail (SHELL_IS_GLOBAL (global));
+
+  global->plugin = plugin;
 }
index 368a66cad4354390250152a571fe617b7a9e9a72..e90c3d36eae77b867a625c29e86d4a1fb8901d99 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef __SHELL_GLOBAL_H__
 #define __SHELL_GLOBAL_H__
 
+#include "mutter-plugin.h"
 #include <clutter/clutter.h>
 #include <glib-object.h>
 
@@ -20,12 +21,8 @@ GType            shell_global_get_type            (void) G_GNUC_CONST;
 
 ShellGlobal *shell_global_get (void);
 
-void shell_global_set_overlay_group (ShellGlobal  *global,
-                                    ClutterActor *overlay_group);
-
-ClutterActor *shell_global_get_overlay_group (ShellGlobal  *global);
-
-void shell_global_print_hello (ShellGlobal *global);
+void _shell_global_set_plugin (ShellGlobal  *global,
+                              MutterPlugin *plugin);
 
 G_END_DECLS